procedure kmp(s, x : string); // X - substr

var       
	n, m, i, q : longint;
	p : array[1..50010] of longint; 
 
	procedure prefix();
	
	var 
		m, k, q : longint;
		
	begin
		fillchar(p, sizeof(p), 0);
		m := length(x);
		p[1] := 0;
		k := 0;
		for q := 2 to m do begin
			while (k > 0) and (x[k + 1] <> x[q]) do 
				k := p[k];
			if x[k + 1] = x[q] then inc(k);
			p[q] := k;
		end;
	end;
 
begin
	n := length(s);
	m := length(x);
	prefix();
	q := 0;
	for i := 1 to n do begin
		while (q > 0) and (x[q + 1] <> s[i]) do 
			q := p[q];
		if x[q + 1] = s[i] then inc(q);
		if q = m then begin
			writeln(i - m);
			q := p[q];
		end;
	end;
end;